
Public Class frmGovernarate
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
    Friend WithEvents lstlist As System.Windows.Forms.ListBox
    Friend WithEvents txtGovernarate As System.Windows.Forms.TextBox
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents cmdsave As DevComponents.DotNetBar.ButtonX
    Friend WithEvents cmdexit As DevComponents.DotNetBar.ButtonX
    Friend WithEvents GroupPanel1 As DevComponents.DotNetBar.Controls.GroupPanel
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.GroupBox1 = New System.Windows.Forms.GroupBox()
        Me.lstlist = New System.Windows.Forms.ListBox()
        Me.txtGovernarate = New System.Windows.Forms.TextBox()
        Me.Label2 = New System.Windows.Forms.Label()
        Me.GroupPanel1 = New DevComponents.DotNetBar.Controls.GroupPanel()
        Me.cmdsave = New DevComponents.DotNetBar.ButtonX()
        Me.cmdexit = New DevComponents.DotNetBar.ButtonX()
        Me.GroupBox1.SuspendLayout()
        Me.GroupPanel1.SuspendLayout()
        Me.SuspendLayout()
        '
        'GroupBox1
        '
        Me.GroupBox1.BackColor = System.Drawing.Color.Transparent
        Me.GroupBox1.Controls.Add(Me.cmdsave)
        Me.GroupBox1.Controls.Add(Me.cmdexit)
        Me.GroupBox1.Controls.Add(Me.lstlist)
        Me.GroupBox1.Controls.Add(Me.txtGovernarate)
        Me.GroupBox1.Controls.Add(Me.Label2)
        Me.GroupBox1.Location = New System.Drawing.Point(28, 6)
        Me.GroupBox1.Name = "GroupBox1"
        Me.GroupBox1.Size = New System.Drawing.Size(587, 328)
        Me.GroupBox1.TabIndex = 9
        Me.GroupBox1.TabStop = False
        '
        'lstlist
        '
        Me.lstlist.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.lstlist.ItemHeight = 18
        Me.lstlist.Location = New System.Drawing.Point(176, 64)
        Me.lstlist.Name = "lstlist"
        Me.lstlist.Size = New System.Drawing.Size(232, 200)
        Me.lstlist.TabIndex = 13
        '
        'txtGovernarate
        '
        Me.txtGovernarate.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.txtGovernarate.Location = New System.Drawing.Point(176, 35)
        Me.txtGovernarate.MaxLength = 30
        Me.txtGovernarate.Name = "txtGovernarate"
        Me.txtGovernarate.Size = New System.Drawing.Size(232, 26)
        Me.txtGovernarate.TabIndex = 8
        '
        'Label2
        '
        Me.Label2.AutoSize = True
        Me.Label2.BackColor = System.Drawing.Color.Transparent
        Me.Label2.Location = New System.Drawing.Point(176, 18)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(125, 18)
        Me.Label2.TabIndex = 9
        Me.Label2.Text = "Governarate Name"
        '
        'GroupPanel1
        '
        Me.GroupPanel1.CanvasColor = System.Drawing.SystemColors.Control
        Me.GroupPanel1.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.Office2007
        Me.GroupPanel1.Controls.Add(Me.GroupBox1)
        Me.GroupPanel1.Dock = System.Windows.Forms.DockStyle.Fill
        Me.GroupPanel1.Location = New System.Drawing.Point(0, 0)
        Me.GroupPanel1.Name = "GroupPanel1"
        Me.GroupPanel1.Size = New System.Drawing.Size(645, 370)
        '
        '
        '
        Me.GroupPanel1.Style.BackColor2SchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground2
        Me.GroupPanel1.Style.BackColorGradientAngle = 90
        Me.GroupPanel1.Style.BackColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground
        Me.GroupPanel1.Style.BorderBottom = DevComponents.DotNetBar.eStyleBorderType.Solid
        Me.GroupPanel1.Style.BorderBottomWidth = 1
        Me.GroupPanel1.Style.BorderColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBorder
        Me.GroupPanel1.Style.BorderLeft = DevComponents.DotNetBar.eStyleBorderType.Solid
        Me.GroupPanel1.Style.BorderLeftWidth = 1
        Me.GroupPanel1.Style.BorderRight = DevComponents.DotNetBar.eStyleBorderType.Solid
        Me.GroupPanel1.Style.BorderRightWidth = 1
        Me.GroupPanel1.Style.BorderTop = DevComponents.DotNetBar.eStyleBorderType.Solid
        Me.GroupPanel1.Style.BorderTopWidth = 1
        Me.GroupPanel1.Style.CornerDiameter = 4
        Me.GroupPanel1.Style.CornerType = DevComponents.DotNetBar.eCornerType.Rounded
        Me.GroupPanel1.Style.TextAlignment = DevComponents.DotNetBar.eStyleTextAlignment.Center
        Me.GroupPanel1.Style.TextColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelText
        Me.GroupPanel1.Style.TextLineAlignment = DevComponents.DotNetBar.eStyleTextAlignment.Near
        Me.GroupPanel1.TabIndex = 26
        Me.GroupPanel1.Text = "Governarate"
        '
        'cmdsave
        '
        Me.cmdsave.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton
        Me.cmdsave.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.cmdsave.ForeColor = System.Drawing.Color.FromArgb(CType(CType(0, Byte), Integer), CType(CType(0, Byte), Integer), CType(CType(64, Byte), Integer))
        Me.cmdsave.Location = New System.Drawing.Point(238, 281)
        Me.cmdsave.Name = "cmdsave"
        Me.cmdsave.Size = New System.Drawing.Size(82, 27)
        Me.cmdsave.TabIndex = 270
        Me.cmdsave.Text = "Save"
        '
        'cmdexit
        '
        Me.cmdexit.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton
        Me.cmdexit.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.cmdexit.ForeColor = System.Drawing.Color.FromArgb(CType(CType(0, Byte), Integer), CType(CType(0, Byte), Integer), CType(CType(64, Byte), Integer))
        Me.cmdexit.Location = New System.Drawing.Point(326, 281)
        Me.cmdexit.Name = "cmdexit"
        Me.cmdexit.Size = New System.Drawing.Size(82, 27)
        Me.cmdexit.TabIndex = 269
        Me.cmdexit.Text = "Exit"
        '
        'frmGovernarate
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(7, 19)
        Me.BackColor = System.Drawing.Color.WhiteSmoke
        Me.ClientSize = New System.Drawing.Size(645, 370)
        Me.ControlBox = False
        Me.Controls.Add(Me.GroupPanel1)
        Me.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None
        Me.Name = "frmGovernarate"
        Me.ShowInTaskbar = False
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent
        Me.GroupBox1.ResumeLayout(False)
        Me.GroupBox1.PerformLayout()
        Me.GroupPanel1.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region

    Dim SQLDreader As SqlClient.SqlDataReader
    Dim GoverId As Integer
    Dim icdata As New DmlDdl
    Private Sub cmdsave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdsave.Click
        If Validation() = True Then Exit Sub
        If cmdsave.Text = "&Save" Then : GoverId = 0
        Else
            cmdsave.Text = "&Save"
            cmdexit.Text = "E&xit"
        End If
        Try
            icdata.DMLGovernarate(txtGovernarate.Text, GoverId)
            MsgBox("Successfully Completed", MsgBoxStyle.Information, "Gulf Chemicals")
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical, "Gulf Chemicals")
        End Try
        Call LoadGovernarate()
        Clear()
    End Sub
    Sub Clear()
        txtGovernarate.Text = ""
        txtGovernarate.Focus()
    End Sub
    Function Validation() As Boolean
        If txtGovernarate.Text = "" Then
            MsgBox("Enter Governarate Name", MsgBoxStyle.Information, "Gulf Chemicals") : txtGovernarate.Focus() : Validation = True
        ElseIf icdata.GetMasterId("GetGoverId", txtGovernarate.Text) <> 0 Then
            MsgBox("Governarate Name already exist", MsgBoxStyle.Information, "Gulf Chemicals") : txtGovernarate.Focus() : Validation = True
        End If
    End Function

    Private Sub Catagory_frm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Location = New Point(30, 150)
        Call LoadGovernarate()
    End Sub

    Sub LoadGovernarate()
        lstlist.Items.Clear()
        Dim dr As SqlClient.SqlDataReader

        Try
            dr = icdata.LoadName("LoadGovernarate")
            While dr.Read
                lstlist.Items.Add(dr("GovernorateName"))
            End While
            dr.Close()
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical, "Gulf Chemicals")
        End Try
    End Sub

    Private Sub lstlist_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles lstlist.DoubleClick
        txtGovernarate.Text = lstlist.SelectedItem
        GetGoverId()
    End Sub

    Private Sub txtcname_TextChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtGovernarate.TextChanged
        icdata.TextChangeEvent(txtGovernarate, lstlist)
    End Sub

    Private Sub txtcname_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtGovernarate.KeyDown
        icdata.KeyDownEvent(e, txtGovernarate, lstlist)
        If e.KeyCode = Keys.Enter Then
            GetGoverId()
        End If
    End Sub
    Sub GetGoverId()
        GoverId = icdata.GetMasterId("GetGoverId", txtGovernarate.Text)
        cmdsave.Text = "&Update"
        cmdexit.Text = "&Cancel"
    End Sub
    Private Sub cmdexit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdexit.Click
        If cmdexit.Text = "E&xit" Then : Me.Close()
        Else
            cmdsave.Text = "&Save"
            cmdexit.Text = "E&xit"
            Clear()
        End If
    End Sub
End Class
